package com.yidu.logisticssystem.service.impl;

import com.yidu.logisticssystem.entity.LogisticsSection;
import com.yidu.logisticssystem.dao.LogisticsSectionDao;
import com.yidu.logisticssystem.service.LogisticsSectionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 部门(LogisticsSection)表服务实现类
 *
 * @author makejava
 * @since 2021-03-08 16:46:53
 */
@Service("logisticsSectionService")
public class LogisticsSectionServiceImpl implements LogisticsSectionService {
    @Resource
    private LogisticsSectionDao logisticsSectionDao;

    /**
     * 通过ID查询单条数据
     *
     * @param sectionId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsSection queryById(Integer sectionId) {
        return this.logisticsSectionDao.queryById(sectionId);
    }

    /**
     * 查询多条数据
     *
     * @return 对象列表
     */
    @Override
    public List<LogisticsSection> queryAllByLimit() {
        return this.logisticsSectionDao.queryAllByLimit();
    }

    /**
     * 新增数据
     *
     * @param logisticsSection 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsSection insert(LogisticsSection logisticsSection) {
        this.logisticsSectionDao.insert(logisticsSection);
        return logisticsSection;
    }

    /**
     * 修改数据
     *
     * @param logisticsSection 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsSection update(LogisticsSection logisticsSection) {
        this.logisticsSectionDao.update(logisticsSection);
        return this.queryById(logisticsSection.getSectionId());
    }

    /**
     * 通过主键删除数据
     *
     * @param sectionId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer sectionId) {
        return this.logisticsSectionDao.deleteById(sectionId) > 0;
    }
}
